Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reversing PDepArrhenius objects containing MultiArrhenius rates #1659

Merged
merged 5 commits into from
Jul 23, 2019

Conversation

mliu49
Copy link
Contributor

@mliu49 mliu49 commented Jul 21, 2019

Motivation or Problem

This really should have been fixed a long time ago, but better late than never.

#329 implemented the capability for the PDepArrhenius class to hold MultiArrhenius rates instead of just Arrhenius rates. This is commonly seen in literature rates, especially from MESS calculations, e.g.

C2H3+O2=CH2CHOO                                    4.07E+27       -4.67    5222.0
  PLOG/1.000E-02    1.55E+24       -5.45    9662.0/
  PLOG/1.000E-02    1.78E-09        4.15    -4707.0/                            ! fit btw. 400 and 1250 K with MAE of 0.4%, 1.2%
  PLOG/1.000E-01    3.48E+56      -15.01    19160.0/
  PLOG/1.000E-01    2.36E+22       -4.52    2839.0/                             ! fit btw. 400 and 1350 K with MAE of 0.2%, 0.5%
  PLOG/3.160E-01    1.25E+64      -16.97    21290.0/
  PLOG/3.160E-01    2.00E+26       -5.43    2725.0/                             ! fit btw. 400 and 1450 K with MAE of 0.2%, 0.6%
  PLOG/1.000E+00    3.34E+61      -15.79    20150.0/
  PLOG/1.000E+00    6.13E+28       -5.89    3154.0/                             ! fit btw. 400 and 1550 K with MAE of 0.2%, 1.1%
  PLOG/3.160E+00    7.34E+53      -13.11    17300.0/
  PLOG/3.160E+00    2.14E+29       -5.80    3520.0/                             ! fit btw. 400 and 1650 K with MAE of 0.3%, 1.5%
  PLOG/1.000E+01    4.16E+48      -11.21    16000.0/
  PLOG/1.000E+01    3.48E+28       -5.37    3636.0/                             ! fit btw. 400 and 1750 K with MAE of 0.4%, 1.9%
  PLOG/3.160E+01    2.33E+43       -9.38    14810.0/
  PLOG/3.160E+01    3.32E+27       -4.95    3610.0/                             ! fit btw. 400 and 1900 K with MAE of 0.6%, 2.5%
  PLOG/1.000E+02    3.41E+39       -8.04    14360.0/
  PLOG/1.000E+02    1.03E+27       -4.72    3680.0/                             ! fit btw. 400 and 2100 K with MAE of 0.9%, 3.1%

As noted in #797, RMG could not reverse these rates and would print the following error:

AttributeError: 'rmgpy.kinetics.arrhenius.MultiArrhenius' object has no attribute 'T0'

Description of Changes

This PR adds the ability to reverse such rates along with a unit test. Since RMG can reverse MultiArrhenius rates, this simply reverses the MultiArrhenius rate associated with each pressure.

This also adds rcond=None to all calls to numpy.linalg.lstsq. In numpy 1.14, the default behavior for the rcond parameter changed. Passing rcond=None silences the warnings printed by numpy and accepts the new default behavior.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.lstsq.html

Testing

Check that tests pass. Jobs containing such rates (e.g. from the Klippenstein_Glarborg2016 kinetics library) will crash during the check collision limit violators step, which is another way to test.

@codecov
Copy link

codecov bot commented Jul 21, 2019

Codecov Report

Merging #1659 into master will increase coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1659      +/-   ##
=========================================
+ Coverage   41.68%   41.7%   +0.01%     
=========================================
  Files         176     176              
  Lines       29342   29341       -1     
  Branches     6050    6049       -1     
=========================================
+ Hits        12232   12237       +5     
+ Misses      16240   16235       -5     
+ Partials      870     869       -1
Impacted Files Coverage Δ
rmgpy/data/kinetics/groups.py 15.15% <0%> (ø) ⬆️
rmgpy/reaction.py 0% <0%> (ø) ⬆️
rmgpy/data/kinetics/family.py 52.9% <0%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 492d3f6...d99d95f. Read the comment docs.

Copy link
Member

@amarkpayne amarkpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code itself looks good, thanks for the PR! I have a couple of quick comments but this looks mostly ready to go. Before you rebase, please swap the order of the commits so that the updated code that allows PDepArrhenius to be reversed comes before the unit test.

rmgpy/reactionTest.py Outdated Show resolved Hide resolved
rmgpy/reactionTest.py Outdated Show resolved Hide resolved
rmgpy/reactionTest.py Show resolved Hide resolved
rmgpy/reactionTest.py Show resolved Hide resolved
@amarkpayne
Copy link
Member

The code itself looks good, thanks for the PR! I have a couple of quick comments but this looks mostly ready to go. Before you rebase, please swap the order of the commits so that the updated code that allows PDepArrhenius to be reversed comes before the unit test.

Just to document it, @mliu49 and I discussed the order of commits offline. It makes more sense as is, as having the test first shows that we have a bug in the old implementation, and then the next commit finally fixes the bug.

Copy link
Member

@amarkpayne amarkpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me. I'll merge this in after the Travis tests pass.

rmgpy/reactionTest.py Outdated Show resolved Hide resolved
Silence numpy warnings and use new default behavior

From numpy documentation:

Changed in version 1.14.0: If not set, a FutureWarning is given.
The previous default of -1 will use the machine precision as rcond
parameter, the new default will use the machine precision times max(M, N).
To silence the warning and use the new default, use rcond=None,
to keep using the old behavior, use rcond=-1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Low Status: Ready for Review PR is complete and ready to be reviewed Type: Error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants